package com.lkcg.demo.model.base;

import com.lkcg.demo.config.tkmybatis.UUIdGenId;
import lombok.Data;
import tk.mybatis.mapper.annotation.KeySql;
import tk.mybatis.mapper.annotation.Version;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * Created by chenzhuobin on 2017/5/22.
 */
@Data
@MappedSuperclass
public class BaseModel implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 实体编号（唯一标识）
     */
    @Id
    @KeySql(genId = UUIdGenId.class)
    @Column(name = "id", length = 32)
    protected String id;

    /**
     * 备注
     */
    @Column(name = "remarks", length = 255)
    protected String remarks;

    /**
     * 创建日期
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_date")
    protected LocalDateTime createDate;

    @Column(name = "create_by")
    protected String createBy;

    /**
     * 更新日期
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "update_date")
    protected LocalDateTime updateDate;

    @Column(name = "update_by")
    protected String updateBy;

    /**
     * 删除标记（0：正常；1：删除；）
     */
    @Column(name = "del_flag")
    protected boolean delFlag;

    /**
     * 数据版本号（更新或删除数据时使用乐观锁机制）
     */
    @Version
    @Column(name = "version")
    protected int version;
}
